<template>
  <div class="homeRoot" v-loading="badyLoading">
    <div class="homeTitle" style="position: relative; margin-top: 0.75rem">
      <div style="position: absolute; top: 3%; z-index: 10; right: 5%">
        <van-button
          type="info"
          size="small"
          style="background: rgb(249, 151, 56)"
          @click="
            () => {
              this.$refs.GGmodel.open();
            }
          "
          v-if="initObj.aboutus"
          >学员公告
        </van-button>
        <!--  v-if="showbtnImg&&!gz.includes('企业班组长')" -->
        <van-button
          type="info"
          size="small"
          style="background: rgb(249, 151, 56)"
          @click="down"
          :loading="vanloading"
          loading-type="spinner"
          loading-text="加载中..."
          v-if="showbtnImg && !gz.includes('企业班组长')"
          >证书下载</van-button
        >
      </div>
      <div
        style="
          position: absolute;
          top: 21%;
          z-index: 1;
          left: 8%;
          font-size: 1.3rem;
          color: #fff;
          width: calc(100vw - (8% + 12px + 6%));
        "
      >
        <p style="width: 100%; display: flex; flex-wrap: nowrap; margin: 0">
          {{ initObj.alias }}
        </p>
      </div>
      <van-swipe class="my-swipe" :autoplay="5000" indicator-color="white">
        <van-swipe-item>
          <img
            style="width: 100%"
            v-if="ishttp.includes('hzdpx')"
            src="@/assets/mobile/hzdpx-banner.png"
            alt=""
          />
          <img
            style="width: 100%"
            v-else
            src="@/assets/mobile/mobile9.png"
            alt=""
          />
        </van-swipe-item>
        <van-swipe-item>
          <img
            style="width: 100%"
            v-if="ishttp.includes('hzdpx')"
            src="@/assets/mobile/hzdpx-banner.png"
            alt=""
          />
          <img
            style="width: 100%"
            v-else
            src="@/assets/mobile/mobile9.png"
            alt=""
          />
        </van-swipe-item>
      </van-swipe>
    </div>
    <div class="functionBox">
      <div class="functionBox_item">
        <div
          style="display: flex; flex-wrap: wrap; justify-content: flex-start"
        >
          <div
            v-for="(item, index) in menuListdata"
            :key="item.id"
            style="display: flex"
          >
            <div
              :class="index % 4 == 0 ? 'modelImgbox noneMargin' : 'modelImgbox'"
              @click="clickMi(item.title)"
            >
              <img :src="item.icon" alt="" />
              <span
                :style="item.title == '知识点试题' ? { width: '110%' } : {}"
                >{{ item.title }}</span
              >
            </div>
          </div>
        </div>
      </div>
      <div class="userInfoBox">
        <div
          style="
            display: flex;
            align-items: center;
            padding: 1rem 0.75rem;
            justify-content: space-between;
            background: #fff;
            padding-bottom: 0;
          "
        >
          <div class="homeTitle" style="padding:0;s">
            <div>
              <van-dropdown-menu active-color="#327BFF">
                <van-dropdown-item
                  v-model="value"
                  :options="option"
                  @change="subjectChange"
                  @open="opendrop"
                />
              </van-dropdown-menu>
            </div>
          </div>
          <div style="display: flex; align-items: center">
            <span style="color: #333; margin-right: 8px; font-size: 1rem">{{
              nickname
            }}</span>
            <img
              v-if="headPicture"
              style="height: 1.5rem; width: 1.5rem; border-radius: 50%"
              :src="headPicture"
              alt=""
            />
            <img
              v-else
              style="height: 1.5rem; width: 1.5rem; border-radius: 50%"
              src="@/assets/logo/logo.png"
              alt=""
            />
          </div>
        </div>
        <div
          style="
            background: #fff;
            padding: 1rem 0.75rem;
            border-radius: 4px;
            margin-bottom: 1px;
          "
        >
          <div
            style="
              background: #f5f5f5;
              color: #d0021b;
              padding: 8px;
              font-weight: 600;
            "
          >
            ↑多科目学员点击切换所有科目
          </div>
        </div>
        <div class="userInfoItem">
          <ul>
            <li>
              <!-- <svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-monixueshi1"></use>
              </svg> -->
              <span> 目标学时 </span>
            </li>
            <li class="SumNumber">
              {{ aim_score }}
              <span style="font-size: 0.75rem; font-weight: 600">学时</span>
            </li>
          </ul>
          <ul>
            <div style="width: 1px; height: 90%; background: #eee"></div>
          </ul>
          <ul>
            <li>
              <!-- <svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-shichang1"></use>
              </svg> -->
              <span> 已学学时 </span>
            </li>
            <li class="SumNumber">
              {{ score_current }}
              <span style="font-size: 0.75rem; font-weight: 600">学时</span>
            </li>
          </ul>
          <ul>
            <div style="width: 1px; height: 90%; background: #eee"></div>
          </ul>
          <ul v-if="showPacy('模拟考试')">
            <li>
              <!-- <svg class="icon" aria-hidden="true">
                <use xlink:href="#icon-wodejifen1"></use>
              </svg> -->
              <span> 模拟练习次数 </span>
            </li>
            <li class="SumNumber">
              {{ exam_count }}
              <span style="font-size: 0.75rem; font-weight: 600">次</span>
            </li>
          </ul>
        </div>
        <div class="jindu">
          <ul>
            <div style="display: flex; align-items: center">
              <li
                style="
                  color: #999;
                  font-size: 0.8rem;
                  margin-right: 10px;
                  max-width: 65px;
                "
              >
                学习进度
              </li>
              <li style="color: #1f48e8; font-weight: 600; font-size: 0.8rem">
                {{ process }}%
              </li>
            </div>
            <li
              style="
                color: #fff;
                font-weight: 400;
                font-size: 0.6rem;
                margin-left: 10px;
                padding: 2.5px 5px;
                border-radius: 6px;
                background: #d0021b;
              "
            >
              (学时增加需学完各知识点课程↓)
            </li>
          </ul>
          <div style="margin-top: 11px">
            <van-progress :percentage="process" :show-pivot="false" />
          </div>
        </div>
      </div>
      <div class="userInfoView" v-loading="loading" v-if="learnisShow">
        <div
          style="
            display: flex;
            align-items: center;
            justify-content: space-between;
          "
        >
          <span
            style="
              color: #fff;
              font-size: 1.1rem;
              font-weight: 600;
              padding: 2px 10px;
              display: flex;
              margin-bottom: 1.12rem;
              justify-content: space-between;
              background: #166aff;
              border-radius: 4px;
            "
            >培训知识点
            <!-- <i
              style="
                color: #f00;
                font-weight: 400;
                font-size: 1rem;
                margin-right: 10px;
              "
              >点击更多查看所有知识点→</i
            > -->
          </span>
          <span
            style="color: #333; font-size: 0.96rem; font-weight: 600"
            @click="
              () => {
                this.$router.push('/study');
              }
            "
          >
            更多
            <van-icon name="arrow" />
          </span>
        </div>
        <div
          style="
            background: #fff;
            padding: 0.5rem 0.75rem;
            border-radius: 4px;
            background: #f5f5f5;
            margin-bottom: 0.75rem;
            color: #d0021b;
            font-weight: 600;
          "
        >
          点击学习下列知识点，查看对应的培训课程，学完所有课程方可增加
          该知识点对应的学时
        </div>
        <ul>
          <!-- <li
            class="content_text_box"
            v-for="item in dataList"
            :key="item.id"
            @click="openvideo(item)"
          >
            <div
              :class="Boolean(item.done) ? 'content_text_boxA' : ''"
              style="width: 6.25rem; margin-right: 12px"
            >
              <img :src="item.cover_path" alt="" />
              <div class="card"></div>
              <div class="cardText">已看完</div>
            </div>
            <div style="max-width: 13.12rem">
              <p>{{ item.title }}</p>
              <span>{{ item.create_time }}</span>
            </div>
          </li> -->
          <li
            class="content_text_box_top"
            v-for="(item, index) in dataList"
            @click="openvideo(item)"
            :style="{
              borderTop: index == 0 ? '1px solid #eee' : '',
            }"
            :key="item.id"
          >
            <div
              style="
                font-size: 1rem;
                font-weight: 600;
                word-wrap: break-word;
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 2;
              "
            >
              {{ item.title }}{{ item.kind == "选学" ? "(选学)" : "" }}
            </div>
            <div style="display: flex; justify-content: space-between">
              <span> {{ item.score }}学时 </span>
              <p
                :style="{
                  color: item.status == '已学完' ? '#f00' : '',
                }"
              >
                {{ item.status == "已学完" ? item.status : "待学习" }}
              </p>
            </div>
          </li>
          <li
            class="content_text_box"
            style="
              align-items: center;
              ustify-content: center;
              border-radius: 14px;
            "
          >
            <van-button
              type="info"
              class="button"
              style="
                width: 100%;
                color: #fff;
                border-radius: 6px;
                position: relative;
              "
              @click="
                () => {
                  this.$router.push('/study');
                }
              "
              >点击查看所有培训课程
              <img
                src="@/assets/mobile/xiaoshou.png"
                style="
                  height: 40px;
                  width: 40px;
                  position: absolute;
                  top: 0px;
                  right: 0;
                "
                alt=""
              />
            </van-button>
          </li>
        </ul>
      </div>
    </div>
    <GGmodel ref="GGmodel"></GGmodel>
    <div style="position: absolute; top: 0; left: 0; z-index: -10; width: 100%">
      <modelPDF :listData="fromData" ref="modelPDF" />
    </div>
    <div style="position: absolute; top: 0; left: 0; z-index: -10">
      <div></div>
    </div>
    <van-popup
      v-model="TCshow"
      :closeable="true"
      :style="{ width: '200px', height: '200px' }"
      position="center"
    >
      <span
        @click="copy"
        style="
          display: flex;
          width: 100%;
          height: 100%;
          justify-content: center;
          align-items: center;
          font-size: 1rem;
          color: #f00;
        "
      >
        点击复制该链接在外部浏览器中打开
      </span>
    </van-popup>
    <van-dialog
      v-model="showdio"
      title="大培训行业选择"
      :before-close="commitEdit"
      theme="round-button"
    >
      <p
        style="
          line-height: 1.8;
          font-size: 16px;
          font-weight: 600;
          padding: 0 15px;
          margin: 12px 0;
        "
      >
        请根据您的所在行业选择对应的行业，并输入上您的所在单位信息。
      </p>
      <van-radio-group v-model="radioEdit">
        <van-radio style="padding: 8px 15px" :name="1092">工贸行业</van-radio>
        <van-radio style="padding: 8px 15px" :name="1091">危化行业</van-radio>
        <van-radio style="padding: 8px 15px" :name="1093"
          >住房建设行业</van-radio
        >
        <van-radio style="padding: 8px 15px" :name="1094">交通运输</van-radio>
        <van-radio style="padding: 8px 15px" :name="1095">矿山行业</van-radio>
        <van-radio style="padding: 8px 15px" :name="1096">民用爆破</van-radio>
        <van-radio style="padding: 8px 15px" :name="1097">烟花爆竹</van-radio>
      </van-radio-group>
      <van-field
        style="border: 1px solid #eee; margin: 8px 15px; width: auto"
        v-model="company"
        label=""
        placeholder="请输入您所在的公司或工作单位"
        border
      />
    </van-dialog>
    <van-dialog
      confirmButtonText="确认签名"
      confirmButtonColor="#000"
      @confirm="signCheck"
      class="isInfo"
      v-model="showInfo"
      title="信息确认"
    >
      <p class="item">
        <span class="lable">身份证号：</span>
        <span class="content">{{ adminUserId }}</span>
      </p>
      <p class="item">
        <span class="lable">姓名:</span>
        <span class="content">{{ nickname }}</span>
      </p>
      <p class="item">
        <span class="lable">资格类型：</span>
        <span class="content">{{ subjectTitle }}</span>
      </p>
      <p class="item">
        <span class="lable">初复训：</span>
        <span class="content">{{ currentInfo.exam_type }}</span>
      </p>
      <p class="item">
        <span class="lable">性别：</span>
        <span class="content">{{ gender }}</span>
      </p>
      <p class="item">
        <span class="lable">健康状态：</span>
        <span class="content">{{ currentInfo.health }}</span>
      </p>
      <p class="item">
        <span class="lable">学历：</span>
        <span class="content">{{ currentInfo.education }}</span>
      </p>
      <p class="item">
        <span class="lable">工作单位：</span>
        <span class="content">{{ company2 }}</span>
      </p>
      <p class="item">
        <span class="lable">证件照：</span>
        <img width="100" height="auto" :src="currentInfo.photo" alt="" />
      </p>
    </van-dialog>
    <van-dialog
      confirmButtonText="确认签名"
      confirmButtonColor="#000"
      @confirm="signCommit"
      class="isInfo"
      v-model="showSign"
      title="签字"
    >
      <autograph :options="options" ref="autograph"> </autograph>
    </van-dialog>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { evaluationLogList } from "@/api/admin";

import {
  getcurrentInfo,
  setsubjectTitle,
  setsubject_id,
  setapplyid,
  getapplyid,
  delapplyid,
  getsubjectTitle,
  getsubject_id,
  setGZ,
  setisphoto,
  delisphoto,
  setispay,
  setLearnTime,
  getGender,
  getGZ,
  setExectSetting,
  getuserstate,
  setuserstate,
  deluserstate,
  setcurrentInfo,
  getUsername,
  getispay,
  delexamSetting,
} from "@/utils/auth.js";
import autograph from "@/components/autograph";
import {
  materialkmlist,
  materialList,
  mywrong,
  mycollect,
  getSetting,
  userlearn,
  getQcount,
  changesid,
  updateApply,
} from "@/api/admin.js";
import { learnImglist } from "@/utils/learnImg.js";
import GGmodel from "./model.vue";
import { downImg } from "@/utils/downloadImg.js";
import { upFileqm } from "@/utils/upFiel.js";
// import face from '@/components/Face/photo.vue'
import modelPDF from "@/components/mobilePDF/modelPDF";
import { download, downloadAll } from "@/api/download.js";
import { Dialog } from "vant";
export default {
  computed: {
    ...mapGetters([
      "userAgent",
      "userinfor",
      "adminUserId",
      "nickname",
      "login_time",
      "Jurisdiction",
      "Jurisdictions",
      "initObj",
      "headPicture",
      "avatar",
    ]),
  },
  components: {
    autograph,
    GGmodel,
    modelPDF,
  },
  data() {
    let http =
      process.env.NODE_ENV === "development"
        ? process.env.VUE_APP_BASE_API
        : window.location.href.slice(0, window.location.href.indexOf("/user"));

    return {
      company2: "",
      hasInfoSign: false,
      options: {
        isDpr: false, //是否使用dpr兼容高倍屏 [Boolean] 可选
        lastWriteSpeed: 1, //书写速度 [Number] 可选
        lastWriteWidth: 2, //下笔的宽度 [Number] 可选
        lineCap: "round", //线条的边缘类型 [butt]平直的边缘 [round]圆形线帽 [square]	正方形线帽
        lineJoin: "bevel", //线条交汇时边角的类型  [bevel]创建斜角 [round]创建圆角 [miter]创建尖角。
        canvasWidth: 280, //canvas宽高 [Number] 可选
        canvasHeight: 280, //高度  [Number] 可选
        isShowBorder: false, //是否显示边框 [可选]
        bgColor: "#fff", //背景色 [String] 可选
        borderWidth: 1, // 网格线宽度  [Number] 可选
        borderColor: "#ff787f", //网格颜色  [String] 可选
        writeWidth: 5, //基础轨迹宽度  [Number] 可选
        maxWriteWidth: 30, // 写字模式最大线宽  [Number] 可选
        minWriteWidth: 5, // 写字模式最小线宽  [Number] 可选
        writeColor: "#101010", // 轨迹颜色  [String] 可选
        isSign: true, //签名模式 [Boolean] 默认为非签名模式,有线框, 当设置为true的时候没有任何线框
        imgType: "png", //下载的图片格式  [String] 可选为 jpeg  canvas本是透明背景的
      },
      valueObj: {},
      signImg: "",
      gender: getGender(),
      subjectTitle: getsubjectTitle(),
      currentInfo: getcurrentInfo() ? JSON.parse(getcurrentInfo()) : {},
      showInfo: false,
      showSign: false,
      ishttp:
        process.env.NODE_ENV === "development"
          ? process.env.VUE_APP_BASE_API
          : window.location.href.slice(
              0,
              window.location.href.indexOf("/user")
            ),
      aligaoao: true,
      option: [],
      value: 0,
      exam_count: "",
      aim_score: "",
      score_current: "",
      process: "",
      dataList: [],
      loading: false,
      vanloading: false,
      badyLoading: false,
      subjct: "",
      sctitle: "实操选学",
      menuList: [
        {
          title: "专项练习",
          icon: require("@/assets/mobile/mobile4.png"),
          id: "1",
        },
        {
          title: "模拟考试",
          icon: require("@/assets/mobile/mobile8.png"),
          id: "2",
        },
        {
          title: http.indexOf("yingji") != -1 ? "模拟练习" : "正式考试",
          icon: require("@/assets/mobile/mobile17.png"),
          id: "3",
        },
        {
          title: "错题库",
          icon: require("@/assets/mobile/mobile14.png"),
          id: "7",
        },
        {
          title: "收藏题库",
          icon: require("@/assets/mobile/mobile13.png"),
          id: "8",
        },
        {
          title: "课程学习",
          icon: require("@/assets/mobile/mobile10.png"),
          id: "4",
        },
        {
          title: "统计",
          icon: require("@/assets/mobile/mobile12.png"),
          id: "9",
        },
        {
          title: "学习记录",
          icon: require("@/assets/mobile/mobile15.png"),
          id: "6",
        },
        {
          title: "操作指南",
          icon: require("@/assets/mobile/mobile11.png"),
          id: "5",
        },
        {
          title: "试题搜索",
          icon: require("@/assets/mobile/mobile16.png"),
          id: "10",
        },
        {
          title: "实操选学",
          icon: require("@/assets/mobile/mobile18.png"),
          id: "11",
        },
        {
          title: "精选题库",
          icon: require("@/assets/mobile/mobile19.png"),
          id: "12",
        },
        ,
        {
          title: "发票申请",
          icon: require("@/assets/mobile/mobile20.png"),
          id: "13",
        },
        {
          title: "题库讲解",
          icon: require("@/assets/mobile/mobile21.png"),
          id: "14",
        },
        {
          title: "附件下载",
          icon: require("@/assets/mobile/mobile22.png"),
          id: "15",
        },
        {
          title: "课程评价",
          icon: require("@/assets/mobile/mobile22.png"),
          id: "16",
        },
        {
          title: "满意度调查",
          icon: require("@/assets/mobile/mobile22.png"),
          id: "19",
        },
        {
          title: "知识点试题",
          icon: require("@/assets/mobile/mobile23.png"),
          id: "17",
        },
        {
          title: "考试报名",
          icon: require("@/assets/mobile/mobile24.png"),
          id: "18",
        },
      ],
      menuListdata: [],
      fromData: {
        nickname: "", //姓名
        username: "", //身份证号
        update_time: "", //发证日期
        start_time: "", //开始时间
        score_finish_time: "", //发证日期
        gender: "", //性别
        subjectTitle: "", //培训科目
        score_loglist: [],
        score_sum: 0, //学时合计
        cert_num: 1010011101111, //证书编号
      },
      IsShowImgBox: false, //展示下载的页面
      showbtnImg: false, //是否展示下载按钮
      TCshow: false,
      downloadURL: "",
      learnisShow: true,
      isJxShow: true,
      showdio: false,
      radioEdit: "",
      company: "",
      isInvoice: false,
      gz: "",
      listData: [],
      baseURL:
        process.env.NODE_ENV === "development"
          ? process.env.VUE_APP_BASE_API
          : window.location.href.slice(
              0,
              window.location.href.indexOf("/user")
            ),
    };
  },
  created() {
    delapplyid();

    if (
      JSON.parse(this.initObj.setting) &&
      JSON.parse(this.initObj.setting).downPine
    ) {
      this.showbtnImg =
        JSON.parse(this.initObj.setting).downPine == "是" ? true : false;
    }
    if (JSON.parse(this.initObj.setting)) {
      this.sctitle = JSON.parse(this.initObj.setting).fonrcan
        ? JSON.parse(this.initObj.setting).fonrcan
        : "实操选学";
    }
    this.menuList.map((item) => {
      if (item.id == "11") {
        item.title = this.sctitle;
      }
    });
    this.option = [];
    this.menuListdata = [];

    this.userinfor.map((item) => {
      let text =
        item.subjectTitle.indexOf("/") !== -1
          ? item.subjectTitle.split("/")[1]
          : item.subjectTitle;
      this.option.push(
        Object.assign(item, { text: text, value: item.subject_id })
      );
    });

    let isfaceMack = "";
    if (this.initObj.is_face) {
      isfaceMack = JSON.parse(this.initObj.is_face);
    } else {
      isfaceMack = "";
    }
    this.value = getsubject_id()
      ? Number(getsubject_id())
      : this.option[0].value;
    if (getsubject_id()) {
      this.option.map((item) => {
        if (getsubject_id() == item.value) {
          this.gz = item.gz;
        }
      });
    } else {
      this.option[0].gz;
    }

    let oaa = false;
    console.log(this.option);
    this.option.map((item) => {
      if (this.value == item.subject_id) {
        oaa = true;
      }
    });
    if (!oaa) {
      this.value = this.option[0].value;
    }
    this.option.map(async (item) => {
      if (this.value == item.subject_id) {
        // this.exam_count = item.gz=='一般工贸'||item.gz=='职业卫生'?item.exam_count_left:item.mock_count_left
        // this.score = item.score
        // this.score_current = item.score_current
        // this.process = item.process
        let exclude_material = item.exclude_material;
        if (exclude_material == "是") {
          this.learnisShow = false;
        } else {
          if (
            this.initObj.exclude_material &&
            this.initObj.exclude_material.split(",").indexOf(this.value + "") !=
              -1
          ) {
            this.learnisShow = false;
          } else {
            this.learnisShow = true;
          }
        }
        setsubject_id(item.value);
        setsubjectTitle(item.text);
        setapplyid(item.applyid);
        setGZ(item.gz);
        // this.getQuest(this.value, item.gz);
        // let gzlist = ['一般工贸','职业卫生','交通运输','全员培训','企业内训']
        await getQcount({
          subjectid: item.value,
          pool: "精选题库",
          applyid: getapplyid(),
        }).then((res) => {
          if (res.code == 200) {
            if (res.data.count > 0) {
              this.isJxShow = true;
            } else {
              this.isJxShow = false;
            }
            this.$forceUpdate();
          }
        });

        userlearn({ applyid: item.applyid }).then((res) => {
          if (res.code == 200) {
            this.getQuest(this.value, item.gz);
            if (res.data.face_recog == "是") {
              if (isfaceMack && isfaceMack[item.gz]) {
                setisphoto(isfaceMack[item.gz]);
              }
            } else {
              delisphoto();
            }
            this.score_current = res.data.score_current;
            this.aim_score = res.data.aim_score;
            this.process = res.data.process;
            this.fromData.nickname = this.nickname;
            this.fromData.username = this.adminUserId;
            this.fromData.gender = getGender();
            Object.assign(this.fromData, JSON.parse(JSON.stringify(res.data)), {
              start_time: this.$moment(res.data.start_time).format(
                "YYYY年MM月DD日"
              ),
              score_finish_time: this.$moment(
                res.data.score_finish_time
              ).format("YYYY年MM月DD日"),
            });
            setcurrentInfo(
              JSON.stringify(
                Object.assign(item, res.data, {
                  score_loglist: {},
                  grade_info: {},
                })
              )
            );
            setLearnTime(this.process);

            this.listData = [this.fromData];
            this.$refs.modelPDF.open(this.fromData);
            this.exam_count = res.data.mock_count_left;
            // item.gz == "一般工贸" || item.gz == "职业卫生"
            //   ? res.data.exam_count_left
            //   : res.data.mock_count_left;
            setispay({
              is_pay: res.data.is_pay,
              test_pay: item.gz == "特种作业" ? res.data.test_pay : "是",
            });
            if (getuserstate() && getuserstate() != "undefined") {
              if (JSON.parse(getuserstate()).applyid != item.applyid) {
                deluserstate();
              }
              if (
                res.data.apply_audit_result.audit_state !=
                JSON.parse(getuserstate()).audit_state
              ) {
                deluserstate();
              }
            }
            if (
              res.data.apply_audit_result &&
              (!getuserstate() || getuserstate() == "undefined")
            ) {
              let str = "";
              if (res.data.apply_audit_result.audit_state == "审核通过") {
                str = `您的个人信息已经审核通过,请到'我的-查看更多'中下载打印您的登记表`;
              } else if (
                res.data.apply_audit_result.audit_state == "审核不通过"
              ) {
                str = `您的个人信息审核未通过,请到'我的-查看更多'中修改您的个人信息并提交`;
              }
              this.$dialog
                .alert({
                  title: "个人信息修改提醒",
                  message: str,
                  confirmButtonText: "确定",
                  allowHtml: true,
                  // callback: action => {
                  //   sessionStorage.setItem('maintain','维护中')
                  // }
                })
                .then(() => {
                  setuserstate(
                    JSON.stringify(
                      Object.assign(res.data.apply_audit_result, {
                        attachment: res.data.attachment,
                      })
                    )
                  );
                })
                .catch(() => {});
            }
            //  this.$router.push('/face?desFace=1')
            // if(gzlist.indexOf(item.gz)){
            //     if(this.score == this.score_current&&item.exam_passit=='不及格'){
            //         this.title=`您的线上培训学习时长已达到${this.score}学时，可以参加正式考试`
            //     }else if(this.score == this.score_current&&item.exam_passit=='及格'){
            //         this.title=`您已通过正式考试，完成本次培训`
            //     }
            // }else{
            //     this.title=`您的线上培训学习时长已达到${this.score}学时`
            // }
            if (isfaceMack && isfaceMack[res.data.gz]) {
              if (
                isfaceMack[res.data.gz].kjface != "关闭" ||
                isfaceMack[res.data.gz].mkface != "关闭" ||
                isfaceMack[res.data.gz].zsface != "关闭" ||
                isfaceMack[res.data.gz].zxface != "关闭"
              ) {
                if (!res.data.face && res.data.face_recog == "是") {
                  let ispay = JSON.parse(getispay());
                  if (
                    (this.initObj.wxpay == "是" && ispay.is_pay == 1) ||
                    this.initObj.wxpay != "是"
                  ) {
                    this.$router.push("/face?desFace=1");
                  }
                }
              }
            }
            this.alertMsg(getGZ());
          }
        });
        // this.menuList.map((item) => {
        //   console.log(item.title,'789');
        //   if (this.showPacy(item.title)) {
        //     this.menuListdata.push(item);
        //   }
        // });
      }
    });

    // this.menuList = this.menuList.filter(item=>{
    //     return this.showPacy(item.title)
    // })

    if (this.ishttp.includes("taihua")) {
      var yes = this.userinfor.some((item) => {
        return item.gz == "全员培训";
      });

      evaluationLogList({ applyid: getapplyid() }).then((res) => {
        if (res.code == 200 && res.data.list.length == 0 && yes) {
          Dialog.alert({
            message: "请完成满意度调查问卷",
          }).then(() => {
            // on close
            this.$router.push("evaluateTaiHua");
          });
        } else {
        }
      });
    }
  },
  mounted() {
    this.FnlistData();
    setTimeout(() => {
      this.subjectTitle = getsubjectTitle();
      this.currentInfo = JSON.parse(getcurrentInfo());
      this.userinfor.map((item) => {
        if (item.applyid == getapplyid()) {
          this.valueObj = item;
          this.company2 = item.company;
          if (
            this.valueObj.extra == null ||
            (this.valueObj.extra && this.valueObj.extra.length == 0)
          ) {
            this.valueObj.extra = {};
          }
          if (this.valueObj.extra.hasOwnProperty("confirmInfo")) {
            this.hasInfoSign = false;
          } else {
            this.hasInfoSign = true;
            if (
              this.ishttp.indexOf("zzfb") != -1 ||
              this.ishttp.indexOf("qiye") != -1
            ) {
              this.showInfo = true;
            }
          }
        }
      });
    }, 2000);

    // document.addEventListener('scroll',this.Fnscroll)
  },
  methods: {
    async signCommit() {
      this.signImg = this.$refs.autograph.commit();
      await upFileqm(this.signImg, this.nickname, {
        field: "signature",
      }).then((res) => {
        if (res.code == 200) {
          this.valueObj.extra.confirmInfo = res.data.url;
        }
      });
      await updateApply(this.valueObj).then((res) => {
        if (res.code == 200) {
          this.$toast.success("信息已确认!");
          this.hasInfoSign = false;
          this.$forceUpdate();
        }
      });
    },
    cancelSign() {
      // this.showInfo = false;
      this.$toast("请确认信息");
    },
    signCheck() {
      this.showSign = true;
    },
    commitEdit(action, done) {
      if (!this.radioEdit) {
        done(false);
        return this.$toast.fail("所选科目不能为空");
      }
      if (!this.company) {
        done(false);
        return this.$toast.fail("所在公司不能为空");
      }
      // subject_id:this.radioEdit,
      changesid({
        applyid: getapplyid(),
        subject_id: this.radioEdit,
        company: this.company,
      }).then((res) => {
        if (res.code == 200) {
          this.$toast.success("操作成功");
          location.reload();
          // this.$store.dispatch('user/userInfo')
          done();
        } else {
          done(false);
          return this.$toast.fail("操作失败");
        }
      });
    },
    alertMsg(gz) {
      // tzsbpx 默认展示3个月<p style="margin: 0;width: 100%;text-align: start;">各位学员：</p>
      let str =
        '<p style="text-indent:28px;text-align: justify;margin: 0;">1、先选择“专项练习”-普通模式-练习题型（单选或多选或判断）-新题-显示答案，按照这个方式学习题库2、然后再用“模拟考试“-随机组卷 -不显示答案，测试学习成果，每做完一套就查看错题，重点背错题。注：除金属焊接、非金属焊接外，其余项目70分及格</p> <p style="text-align: end;margin: 0;">请各位学员知悉。</p>';
      if (!sessionStorage.getItem("Amaintain") && gz == "特种设备") {
        if (!this.qyType("tzsbpx")) {
          this.$dialog
            .alert({
              title: "重  要  公  告",
              message: str,
              confirmButtonText: "确定",
              allowHtml: true,
              // callback: action => {
              //   sessionStorage.setItem('maintain','维护中')
              // }
            })
            .then(() => {
              sessionStorage.setItem("Amaintain", "1");
            })
            .catch(() => {});
        }
      }
      // &&!this.qyType('hzdpx')
      if (
        (getsubject_id() == "472" || !this.fromData.company) &&
        !this.qyType("hzdpx")
      ) {
        this.showdio = true;
      }
      if (!this.qyType("testtjy")) {
        this.showdio = false;
      }
    },
    // algma() {
    //   this.aligaoao = false;
    // },
    // trjs() {
    //   this.aligaoao = true;
    // },
    Fnscroll() {
      //rootModel  461
      let el = document.getElementsByClassName("rootModel")[0]; // 滚动元素
      let box = document.getElementsByClassName("userInfoBox")[0]; //当前元素
      const tragetElemPostition = box.offsetTop; // 当前元素距离文档顶部高度
      // 当前滚动高度
      let scrollTop = el.scrollTop;
      // 滚动step方法
      const step = function () {
        // 距离目标滚动距离
        let distance = tragetElemPostition - scrollTop;
        // 目标需要滚动的距离，也就是只走全部距离的五分之一
        scrollTop = scrollTop + distance / 5;
        if (Math.abs(distance) < 1) {
          el.scrollTo(0, tragetElemPostition);
        } else {
          el.scrollTo(0, scrollTop);
          setTimeout(step, 40);
        }
      };
      step();
    },
    async opendrop() {
      this.Fnscroll();
      await this.$store.dispatch("user/userInfo");
    },
    subjectChange(value) {
      delexamSetting();
      this.badyLoading = true;
      let isfaceMack = "";
      if (this.initObj.is_face) {
        isfaceMack = JSON.parse(this.initObj.is_face);
      } else {
        isfaceMack = "";
      }
      this.option.map(async (item) => {
        if (item.value == value) {
          setapplyid(item.applyid);
          setsubjectTitle(item.text);
          setsubject_id(item.value);
          setGZ(item.gz);
          this.gz = item.gz;
          // if(item.face_recog=='是'){
          //     if(isfaceMack&&isfaceMack[item.gz]){
          //         setisphoto(isfaceMack[item.gz])
          //     }
          // }

          let exclude_material = item.exclude_material;
          if (exclude_material == "是") {
            this.learnisShow = false;
          } else {
            if (
              this.initObj.exclude_material &&
              this.initObj.exclude_material
                .split(",")
                .indexOf(item.value + "") != -1
            ) {
              this.learnisShow = false;
            } else {
              this.learnisShow = true;
            }
          }
          this.aim_score = item.aim_score;
          this.score_current = item.score_current;
          this.process = item.process;
          getQcount({
            subjectid: item.value,
            pool: "精选题库",
            applyid: getapplyid(),
          }).then((res) => {
            if (res.code == 200) {
              if (res.data.count > 0) {
                this.isJxShow = true;
              } else {
                this.isJxShow = false;
              }
            }
          });
          // let gzlist = ['一般工贸','职业卫生','交通运输','全员培训','企业内训']
          await userlearn({ applyid: item.applyid }).then((res) => {
            if (res.code == 200) {
              this.badyLoading = false;
              this.getQuest(item.value, item.gz);
              Object.assign(
                this.fromData,
                JSON.parse(JSON.stringify(res.data)),
                {
                  start_time: this.$moment(res.data.start_time).format(
                    "YYYY年MM月DD日"
                  ),
                  score_finish_time: this.$moment(
                    res.data.score_finish_time
                  ).format("YYYY年MM月DD日"),
                }
              );
              if (res.data.face_recog == "是") {
                if (isfaceMack && isfaceMack[item.gz]) {
                  setisphoto(isfaceMack[item.gz]);
                }
              } else {
                delisphoto();
              }
              if (getuserstate() && getuserstate() != "undefined") {
                if (JSON.parse(getuserstate()).applyid != item.applyid) {
                  deluserstate();
                }
                if (
                  res.data.apply_audit_result.audit_state !=
                  JSON.parse(getuserstate()).audit_state
                ) {
                  deluserstate();
                }
              }
              setcurrentInfo(
                JSON.stringify(
                  Object.assign(item, res.data, {
                    score_loglist: {},
                    grade_info: {},
                  })
                )
              );

              if (
                res.data.apply_audit_result &&
                (!getuserstate() || getuserstate() == "undefined")
              ) {
                let str = "";
                if (res.data.apply_audit_result.audit_state == "审核通过") {
                  str = `您的个人信息已经审核通过,请到'个人信息'菜单处下载打印您的登记表`;
                } else if (
                  res.data.apply_audit_result.audit_state == "审核不通过"
                ) {
                  str = `您的个人信息审核未通过,请到'个人信息'菜单处修改您的个人信息并提交`;
                }
                this.$dialog
                  .alert({
                    title: "个人信息修改提醒",
                    message: str,
                    confirmButtonText: "确定",
                    allowHtml: true,
                    // callback: action => {
                    //   sessionStorage.setItem('maintain','维护中')
                    // }
                  })
                  .then(() => {
                    setuserstate(
                      JSON.stringify(
                        Object.assign(res.data.apply_audit_result, {
                          attachment: res.data.attachment,
                        })
                      )
                    );
                  })
                  .catch(() => {});
              }
              this.exam_count = res.data.mock_count_left;
              this.score_current = res.data.score_current;
              this.aim_score = res.data.aim_score;
              this.process = res.data.process;
              this.fromData.nickname = this.nickname;
              this.fromData.username = this.adminUserId;
              this.fromData.gender = getGender();
              this.listData = [this.fromData];
              this.$refs.modelPDF.open(this.fromData);
              setLearnTime(this.process);
              this.alertMsg(item.gz); //提醒设置
              setispay({
                is_pay: res.data.is_pay,
                test_pay: item.gz == "特种作业" ? res.data.test_pay : "是",
              });
              // if(gzlist.indexOf(item.gz)){
              //     if(this.score == this.score_current&&item.exam_passit=='不及格'){
              //         this.title=`您的线上培训学习时长已达到${this.score}学时，可以参加正式考试`
              //     }else if(this.score == this.score_current&&item.exam_passit=='及格'){
              //         this.title=`您已通过正式考试，完成本次培训`
              //     }
              // }else{
              //     this.title=`您的线上培训学习时长已达到${this.score}学时`
              // }
              if (isfaceMack && isfaceMack[res.data.gz]) {
                if (
                  isfaceMack[res.data.gz].kjface != "关闭" ||
                  isfaceMack[res.data.gz].mkface != "关闭" ||
                  isfaceMack[res.data.gz].zsface != "关闭" ||
                  isfaceMack[res.data.gz].zxface != "关闭"
                ) {
                  if (!res.data.face && res.data.face_recog == "是") {
                    let ispay = JSON.parse(getispay());
                    if (
                      (this.initObj.wxpay == "是" && ispay.is_pay == 1) ||
                      this.initObj.wxpay != "是"
                    ) {
                      this.$router.push("/face?desFace=1");
                    }
                  }
                }
              }
            }
          });
          this.FnlistData();
        }
      });
    },
    fileList() {
      this.dataList = [];
      this.loading = true;
      // materialList({
      //   msid: this.subjct,
      //   file_type: "",
      //   page: 1,
      //   limit: 100,
      // }).then((res) => {
      //   this.loading = false;
      //   if (res.code == 200) {
      //     res.data.list.map((item) => {
      //       let list = JSON.parse(item.material_subject_full);
      //       if (!item.cover_path) {
      //         for (let i = 0; i < learnImglist.length; i++) {
      //           for (let k = 0; k < list.length; k++) {
      //             let el = list[k];
      //             if (
      //               el &&
      //               el.indexOf(learnImglist[i].id) != -1 &&
      //               (el.indexOf(learnImglist[i].id) - el.indexOf(this.subjct) <
      //                 2 ||
      //                 el.indexOf(learnImglist[i].id) - el.indexOf(this.subjct) >
      //                   2)
      //             ) {
      //               item.cover_path = learnImglist[i].src;
      //               break;
      //             }
      //           }
      //           // for(let k=0;k<list.length;k++){
      //           // }
      //         }
      //       }
      //     });
      //     this.dataList = res.data.list;
      //   }
      // });
      // materialkmlist({
      //   msid: getsubject_id(),
      //   applyid: getapplyid(),
      //   cate: "理论",
      // }).then(res=>{
      //   if(res.code==200){
      //     this.dataList= res.data
      //   }
      // })
    },
    async FnlistData() {
      this.list = [];
      await materialkmlist({
        msid: this.value,
        applyid: getapplyid(),
        cate: "理论",
      }).then((res) => {
        console.log(12333333);
        if (res.code == 200 && res.data.length != 0) {
          let item = res.data[0];
          this.subjct = item.id;
          // this.dataList = res.data;
          let arr1 = [];
          let arr2 = [];
          res.data.map((item) => {
            if (item.status == "已学完") {
              arr1.push(item);
            } else {
              arr2.push(item);
            }
          });
          this.dataList = [...arr2, ...arr1];
          // this.fileList();
        }
      });
    },
    //我的错题
    mineError() {
      mywrong({ subjectid: getsubject_id() }).then((res) => {
        if (res.code == 200) {
          if (res.data.length <= 0) {
            this.$toast.fail("您还没有错题记录,快去练习吧");
          } else {
            this.$store.commit("SET_TI", res.data);
            this.$router.push(
              "/exam?gz=" +
                this.gz +
                "&daan=显示" +
                "&titleName=模拟考试" +
                "&usererror=错题集&subjectid=" +
                getsubject_id()
            );
          }
        }
      });
    },
    //我的收藏
    mineCanlt() {
      mycollect({ subjectid: getsubject_id() }).then((res) => {
        if (res.code == 200) {
          if (res.data.length <= 0) {
            this.$toast.fail("您还没有收藏试题,快去收藏吧");
          } else {
            this.$store.commit("SET_TI", res.data);
            this.$router.push(
              "/exam?gz=" +
                this.gz +
                "&daan=显示" +
                "&titleName=模拟考试" +
                "&usererror=收藏&subjectid=" +
                getsubject_id()
            );
          }
        }
      });
    },
    //点击操作指南
    openCaozuo() {
      this.$dialog.alert({
        message: "请点击下方培训课程，点击更多学习完成所有大纲培训课程。",
        messageAlign: "left",
      });
    },
    //打开视频 或课件
    openvideo(item) {
      // if (item.file_type == "视频") {
      //   this.$router.push("/video?id=" + item.id + "&subjctid=" + this.subjct);
      // }
      // if (item.file_type == "课件") {
      //   this.$router.push(
      //     "/PDF?id=" +
      //       item.id +
      //       "&subjctid=" +
      //       this.subjct +
      //       "&pdf=" +
      //       item.file_path
      //   );
      // }
      // this.$router.push("/video?id=" + item.id + "&subjctid=" + this.subjct);
      this.$router.push({
        path: "/study",
        query: item,
      });
    },
    //特殊模块权限

    async getQuest(subjectid, gz) {
      await getSetting({ subjectid: subjectid, gz: gz }).then((res) => {
        if (res.code == 200) {
          let obj = res.data;
          let str = {};
          let arr = ["初级", "中级", "高级", "技师"];
          let Arr = JSON.parse(JSON.stringify(this.menuList));
          this.$store.dispatch("user/commitJurisdictions", res.data);
          if (
            gz == "职业技能等级认定" &&
            (this.ishttp.indexOf("qdjsxy") != -1 ||
              this.ishttp.indexOf("qiye") != -1 ||
              this.ishttp.indexOf("testtjy") != -1)
          ) {
            arr.map((item) => {
              if (getsubjectTitle().indexOf(item) != -1) {
                this.$store.dispatch("user/commitJurisdiction", {
                  模拟考试: obj.模拟考试[item].模块展示,
                  正式考试: obj.正式考试[item].模块展示,
                  专项练习: obj.专项练习.模块展示,
                  课程学习: this.learnisShow,
                });
                str = res.data.模拟考试[item];
              }
            });
          } else {
            this.$store.dispatch("user/commitJurisdiction", {
              模拟考试: obj.模拟考试.模块展示,
              正式考试: obj.正式考试.模块展示,
              专项练习: obj.专项练习.模块展示,
              课程学习: this.learnisShow,
            });
            str = res.data.模拟考试;
          }
          setExectSetting(Object.assign(str, { 考试类型: "模拟考试" }));
          // if (
          //   obj.模拟考试.模块展示 == "显示" &&
          //   obj.正式考试.模块展示 == "显示" &&
          //   obj.专项练习.模块展示 == "显示"
          // ) {
          //   this.$store.dispatch("user/commitJurisdiction", "3");
          // } else if (obj.模拟考试.模块展示 == "显示") {
          //   this.$store.dispatch("user/commitJurisdiction", "1");
          // } else if (obj.正式考试.模块展示 == "显示") {
          //   this.$store.dispatch("user/commitJurisdiction", "2");
          // } else if (obj.专项练习.模块展示 == "显示") {
          //   this.$store.dispatch("user/commitJurisdiction", "0");
          // } else {
          //   this.$store.dispatch("user/commitJurisdiction", "9");
          // }
          this.menuListdata = [];
          this.$nextTick(() => {
            this.menuList.map((item) => {
              if (this.showPacy(item.title)) {
                this.menuListdata.push(item);
              }
            });
          });
          this.$forceUpdate();
        }
      });
    },
    //显示隐藏模块
    showPacy(item) {
      switch (item) {
        case "收藏题库":
          return this.Jurisdictions.收藏题库
            ? this.Jurisdictions.收藏题库.模块展示 == "显示"
            : false;
        case "错题库":
          return this.Jurisdictions.错题库
            ? this.Jurisdictions.错题库.模块展示 == "显示"
            : false;
        case "模拟考试":
          return this.Jurisdictions.模拟考试
            ? this.Jurisdictions.模拟考试.模块展示 == "显示"
            : false;
        case "正式考试":
          return this.Jurisdictions.正式考试
            ? this.Jurisdictions.正式考试.模块展示 == "显示"
            : false;
        case "模拟练习":
          return this.Jurisdictions.正式考试
            ? this.Jurisdictions.正式考试.模块展示 == "显示"
            : false;
        case "专项练习":
          return this.Jurisdictions.专项练习
            ? this.Jurisdictions.专项练习.模块展示 == "显示"
            : false;
        case "试题搜索":
          return this.Jurisdictions.试题搜索
            ? this.Jurisdictions.试题搜索.模块展示 == "显示"
            : false;
        case this.sctitle:
          return JSON.parse(this.initObj.setting).SCstudent
            ? JSON.parse(this.initObj.setting).SCstudent == "是"
            : false;
        case "课程学习":
          return this.learnisShow;
        case "学习记录":
          return this.learnisShow;
        case "精选题库":
          return this.isJxShow;
        case "发票申请":
          return this.ishttp.indexOf("qdjsxy") != -1 ||
            this.ishttp.indexOf("yzza") != -1 ||
            this.ishttp.indexOf("lyky") != -1 ||
            (this.ishttp.indexOf("bosheng") != -1 &&
              this.gz == "燃气从业人员培训")
            ? true
            : false;
        case "题库讲解":
          return JSON.parse(this.initObj.setting).TKstudent
            ? JSON.parse(this.initObj.setting).TKstudent == "是"
            : false;
        case "附件下载":
          return this.ishttp.includes("hongjing");
        case "知识点试题":
          return this.ishttp.includes("xingye");
        case "考试报名":
          return (
            this.ishttp.includes("lyjc") &&
            ["特种作业", "安全管理"].includes(this.gz)
          );
        case "课程评价":
          return (
            this.ishttp.includes("qiye") ||
            (this.ishttp.includes("huacong") && this.process >= 100) ||
            (this.ishttp.includes("sdtjy") && this.process >= 100) ||
            (this.ishttp.includes("jtlzy") && this.process >= 100) ||
            (this.ishttp.includes("jyhc") && this.process >= 100) ||
            (this.ishttp.includes("kmjd") && this.process >= 100)
          );
        case "满意度调查":
          return this.ishttp.includes("qiye") || this.ishttp.includes("taihua");
        default:
          return true;
      }
    },
    //点击模块
    clickMi(title) {
      var path = "";
      if (this.ishttp.includes("huacong") && this.process >= 100) {
        path = "evaluate";
      } else if (
        (this.ishttp.includes("taihua") && this.process >= 100) ||
        this.ishttp.includes("qiye")
      ) {
        path = "evaluateTaiHua";
      } else {
        path = "evaluateIndex";
      }
      switch (title) {
        case "专项练习":
          this.$router.push("/practice");
          break;
        case "模拟考试":
          this.$router.push("/practice?titleName=模拟考试");
          break;
        case "正式考试":
          this.$router.push("/practice?titleName=正式考试");
          break;
        case "模拟练习":
          this.$router.push("/practice?titleName=正式考试");
          break;
        case "课程学习":
          this.$router.push("/study");
          break;
        case "操作指南":
          this.openCaozuo();
          break;
        case "学习记录":
          this.$router.push("/record");
          break;
        case "错题库":
          this.mineError();
          break;
        case "收藏题库":
          this.mineCanlt();
          break;
        case "统计":
          // statistics
          this.$router.push("/statistics");
          break;
        case "试题搜索":
          // statistics
          this.$router.push("/questionsSearch");
          break;
        case this.sctitle:
          // statistics
          this.$router.push("/SCstudy");
          break;
        case "精选题库":
          // statistics
          this.$router.push("/practice?isjx=精选题库");
          break;
        case "发票申请":
          // statistics
          this.$router.push(`/Invoice?gz=${this.gz}`);
          break;
        case "题库讲解":
          // statistics
          this.$router.push(`/SCstudy?isvideo=${true}`);
          break;
        case "附件下载":
          this.$router.push("/annex?list=" + JSON.stringify(this.fromData));
          break;
        case "课程评价":
          this.$router.push(`/${path}?id=` + getapplyid());
          break;
        case "满意度调查":
          this.$router.push(`/${path}?id=` + getapplyid());
          break;
        case "知识点试题":
          this.$router.push("knowlage");
          break;
        case "考试报名":
          this.$router.push("knowlage");
          break;
      }
    },
    //考试报名
    examSubmit() {
      this.$dialog
        .confirm({
          title: "提示",
          message:
            "请确认您已完成线上理论学时,模拟考试成绩3次超过85分后可以自行申请参加考试",
          confirmButtonText: "确认",
          cancelButtonText: "取消",
        })
        .then(() => {
          updateApply({ applyid: getapplyid(), apply_exam: 1 }).then((res) => {
            if (res.code == 200) {
              this.$toast.success(res.msg);
            } else {
              this.$toast.fail(res.msg);
            }
          });
        })
        .catch();
    },
    //证书下载
    down() {
      if (this.process < 100) {
        return this.$toast.fail("学时不足,不能下载证书!");
      }
      //正式考试不及格
      if (
        this.fromData.exam_passit != "及格" &&
        (this.fromData.gz == "一般工贸" || this.fromData.gz == "职业卫生") &&
        getUsername() != "372924199607068671" &&
        this.baseURL.includes("ataq")
      ) {
        return this.$toast.fail("考试未通过或未参加考试，不能下载证书!");
      }
      //模拟考试不及格
      if (
        this.fromData.mock_passit != "及格" &&
        this.baseURL.includes("ycjg")
      ) {
        return this.$toast.fail("考试未通过或未参加考试，不能下载证书!");
      }
      if (!this.fromData.cert_pdf_link.includes("http")) {
        if (!this.fromData.cert_pdf_link) {
          return this.$toast.fail("暂未生成证书,请联系管理员生成!");
        } else {
          return this.$toast.fail(
            "无法打印证书原因:" + this.fromData.cert_pdf_link
          );
        }
      }
      // if (!this.fromData.cert_pdf_link) {
      //   return this.$toast.fail("暂未生成证书,请联系管理员生成!");
      // }
      // download(this.fromData.cert_pdf_link,`${this.nickname}的证书.pdf`)
      // return

      this.$nextTick(() => {
        let MicroMessenger = navigator.userAgent.match(/MicroMessenger/i);
        if (MicroMessenger) {
          // this.TCshow = true;
          // this.downloadURL= this.fromData.cert_pdf_link
          // https://t.asczwa.com/taobao?backurl=
          if (navigator.userAgent.match(/iPhone OS .*?(?= )/)) {
            const link = document.createElement("a");
            let that = this;
            link.style.display = "none";
            fetch(this.fromData.cert_pdf_link)
              .then((res) => {
                return res.blob();
              })
              .then((blob) => {
                link.href = URL.createObjectURL(blob);
                link.download = `${that.nickname}的证书.pdf`;
                document.body.appendChild(link);
                link.click();
                document.body.removeChild(link);
                URL.revokeObjectURL(blob);
              });
          } else {
            download(
              this.fromData.cert_pdf_link + "?mp.wexin.qq.com",
              `${this.nickname}的证书.pdf`
            );
          }
        } else {
          // downloadAll(this.fromData.cert_pdf_link,`${this.nickname}的证书.pdf`)
          const link = document.createElement("a");
          let that = this;
          link.style.display = "none";
          fetch(this.fromData.cert_pdf_link)
            .then((res) => {
              return res.blob();
            })
            .then((blob) => {
              link.href = URL.createObjectURL(blob);
              link.download = `${that.nickname}的证书.pdf`;
              document.body.appendChild(link);
              link.click();
              document.body.removeChild(link);
              URL.revokeObjectURL(blob);
            });
        }
        // downImg("证书", "pdfDomD").then((res) => {
        //   this.vanloading=false
        //   this.TCshow = true;
        //   this.downloadURL = res;
        //   // this.IsShowImgBox = false;
        // });
      });
    },
    copy() {
      let url = this.downloadURL;
      let oInput = document.createElement("input");
      oInput.value = url;
      document.body.appendChild(oInput);
      oInput.select(); // 选择对象;
      document.execCommand("Copy"); // 执行浏览器复制命令
      this.$toast.success("复制成功");
      oInput.remove();
    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep {
  .isInfo {
    padding: 1rem;
    .van-dialog__header {
      padding-top: 0;
      padding-bottom: 1rem;
    }
    .item {
      display: flex;
      justify-content: left;
      .lable {
        flex-shrink: 0;
        width: 5rem;
        display: inline-block;
      }
      .content {
        width: 14rem;
      }
    }
  }
}
.icon {
  width: 0.875rem;
  height: 0.875rem;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
::v-deep {
  .homeTitle {
    .van-ellipsis {
      // font-size: 1rem !important;
      word-wrap: break-word !important;
      word-break: normal !important;
      width: 40vw;
      color: #fff;
      font-size: 0.9rem;
    }
  }
  .my-swipe {
    border-radius: 6px;
  }
  .van-dropdown-menu__item {
    flex: none !important;
    .van-dropdown-menu__title {
      padding: 0.4rem;
      padding-right: 0.85rem;
      background: rgb(249, 151, 56);
      border-radius: 10px;
    }
    .van-dropdown-menu__title::after {
      border-color: transparent transparent #fff #fff;
      right: 6px;
    }
    .van-dropdown-menu__title--active::after {
      border-color: transparent transparent currentColor currentColor;
    }
  }
  .van-dropdown-menu__bar {
    box-shadow: none;
    height: auto !important;
  }
  .van-progress {
    height: 10px;
    border-radius: 6px;
    .van-progress__portion {
      height: 100%;
      background: #1f48e8;
    }
  }
  .van-dialog__header {
    font-weight: 600;
  }
}
.homeRoot {
  overflow: hidden;
  position: relative;
  .homeTitle {
    padding: 0 12px;
    background: #fff;
    position: relative;
  }
  .functionBox {
    padding: 0 12px;
    padding-bottom: 12px;
    .functionBox_item {
      background: #fff;
      margin-top: 12px;
      padding: 12px 1.31rem;
      padding-bottom: 0;
      border-radius: 4px;
      .modelImgbox {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
        height: 4.5rem;
        width: calc((100vw - 42px - 24px - 100px) / 4);
        margin-left: 2rem;
        margin-bottom: 12px;
        img {
          width: 3rem;
          height: 3rem;
        }
        span {
          font-size: 0.75rem;
        }
      }
      .noneMargin {
        margin-left: 0;
      }
    }
    .userInfoBox {
      margin-top: 12px;
      // padding: 12px;
      padding-bottom: 0;
      // background: #fff;
      border-radius: 4px;

      .userInfoItem {
        display: flex;
        justify-content: space-between;
        // padding-bottom: 0.94rem;
        border-bottom: 1px solid #eee;
        background: #fff;
        padding: 0.9rem 1.25rem 1.5rem;

        ul {
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          align-items: center;
          height: 3.06rem;
          .SumNumber {
            font-weight: 600;
            font-size: 1.44rem;
            font-family: "DIN Alternate Bold";
          }
        }
      }
      .jindu {
        padding: 0.94rem 0.75rem;
        background: #fff;
        width: 100%;
        ul {
          display: flex;
          align-items: center;
          width: 100%;
          justify-content: space-between;
        }
      }
    }
    .userInfoView {
      margin-top: 12px;
      padding: 12px;
      background: #fff;
      border-radius: 4px;
      .content_text_box_top {
        flex-direction: column;
        display: flex;
        justify-content: space-between;
        // height: 5.16rem;
        padding: 0.5rem 0;
        border-bottom: 1px #eee solid;
      }
      .content_text_box {
        display: flex;
        height: 5.16rem;
        margin: 0.75rem 0;
        justify-content: flex-start;

        img {
          height: 100%;
          width: 6.25rem;
          border-radius: 4px;
          margin-right: 0.75rem;
        }
        p {
          margin: 0;
          font-weight: 600;
          font-size: 0.97rem;
          padding: 6px 0;
        }
        & > span {
          font-size: 0.75rem;
          color: #aaa;
        }
      }
    }
  }
}
.card {
  display: none;
  width: 6.25rem;
  height: 1rem;
  background: #f00;
  position: absolute;
  transform: rotate(40deg);
  top: 10px;
  right: -35px;
}
.cardText {
  display: none;
  position: absolute;
  // padding:10px;
  font-size: 0.75rem;
  transform: rotate(40deg);
  top: 7px;
  right: -1px;
  color: #fff;
  z-index: 2;
}
.content_text_boxA {
  position: relative;
  overflow: hidden;
  width: 6.25rem;
  margin-right: 1rem;
  .card {
    display: block;
  }
  .cardText {
    display: block;
  }
}
</style>
